home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / asyncom.arc / QSEND.BAS < prev    next >
Encoding:
BASIC Source File  |  1987-07-28  |  3.5 KB  |  123 lines

  1. '     QSEND and QRECV are used in conjunction to transmit files from one
  2. ' computer to another when they have incompatible diskette drives and there's
  3. ' no other way for them to communicate.  All that is nessecary is to have
  4. ' QRECV running on the receiving end, QSEND running on the sending end, and
  5. ' a cable connecting the COM1 port on both machines.  The cable can be very
  6. ' simple, composed of as few as four wires; ground, transmitted data,
  7. ' received data, and data terminal ready.  The cable should be wired pin 2
  8. ' to pin 3, pin 3 to pin 2, pin 7 to pin 7 and pin 20 to pin 20.
  9. '
  10. '     If you have no simple way to download these files to both systems,
  11. ' then the short interpreted basic programs SEND and RECV can be type on the
  12. ' other end and used to transfer these files to that end.  If they fail to
  13. ' work, try using a larger communications buffer (use BASICA/C:XXXX), and
  14. ' adding wait loops to SEND to slow it down.
  15. '
  16. '     Both SEND and QSEND have the ability to accept a file name that is a
  17. ' list of the files you want to move.  The file must use 'SND' as it's
  18. ' extension, and the file names must be entered one to a line in the first
  19. ' twelve characters of the line.  The file can be created by redirecting
  20. ' the DIR command to a file (I.E.>  DIR > FILE.SND), and then edited to
  21. ' remove all the lines that aren't file names, or that you don't want
  22. ' to move.
  23. '
  24. '     QSEND and QRECV use a very simple check byte after each block.  It
  25. ' has been useful for us, but it isn't very comprehensive.  It should
  26. ' offer a good place to start experimenting, and it really is a great
  27. ' help when your trying to get files onto a PS/2 without a network.
  28. ' When you compile them, be sure to set the communications buffer at 1K
  29. ' or higher (\C:1024).
  30. '
  31. '     Donald Cross
  32. '     Systems Programmer
  33. '     Fairmont Railway Motors
  34. '     Fairmont MN, 56031
  35.  
  36.  
  37.     DEFINT A-Z
  38.     TV$=CHR$(255)
  39.     OPEN "com1:9600,n,8,1,rs,cs,ds,cd" AS #1
  40.  
  41. 40
  42.     IF LF THEN _
  43.       210 _
  44.     ELSE _
  45.       CLS _
  46.       :LOCATE 3,20 _
  47.       :PRINT "QSEND - Asynchronous file transfer utility" _
  48.       :locate 5,10 _
  49.       :INPUT"File to send";F$ _
  50.       :IF F$="" THEN _
  51.     CLOSE _
  52.     :END
  53.     T=INSTR(1,F$,".")
  54.     IF T>0 THEN _
  55.       T$=MID$(F$,T+1,3) _
  56.       :IF T$="SND" OR T$="snd" THEN _
  57.         LF=1 _
  58.         :GOTO 200
  59.  
  60. 50
  61.     OPEN F$ FOR INPUT AS #2
  62.     CLOSE 2
  63.     OPEN F$ AS #2 LEN=512
  64.     FIELD#2, 512 AS B$
  65.     L!=LOF(2)
  66.     SEND.LEN=LEN(F$)+4
  67.     MID$(B$,1,SEND.LEN)=MKS$(L!)+F$
  68.     GOSUB SEND.RTN
  69.     T!=0
  70.     BC=0
  71.     LOCATE 7,5
  72.     PRINT "Sending ";F$;L!;"bytes,";INT(L!/512)+1;"blocks        "
  73.     SEND.LEN=512
  74.     WHILE T!<L!
  75.       GET#2
  76.       T!=T!+512
  77.       IF T!>L! THEN _
  78.     SEND.LEN=512-(T!-L!)
  79.       GOSUB SEND.RTN
  80.     WEND
  81.     CLOSE 2
  82.     GOTO 40
  83.  
  84. 200
  85.     OPEN F$ FOR INPUT AS #3
  86.  
  87. 210
  88.     IF EOF(3) THEN _
  89.       LF=0 _
  90.       :CLOSE 3 _
  91.       :GOTO 40
  92.     INPUT#3, F$
  93.     F$=LEFT$(F$,8)+"."+MID$(F$,10,3)
  94.     GOTO 50
  95.  
  96. SEND.RTN:
  97.     BC=BC+1
  98.     LOCATE 10,10
  99.     PRINT "Block"; BC
  100.     RC=0
  101.     CB=0
  102.     FOR J=1 TO SEND.LEN
  103.       CB=CB+ASC(MID$(B$,J,1))
  104.       CB=CB-INT(CB/256)*256
  105.     NEXT
  106.     WHILE LOC(1)>0
  107.       T$=INPUT$(1,#1)
  108.     WEND
  109. SEND.RETRY:
  110.     PRINT #1, TV$;LEFT$(MKI$(CB),1);MKI$(SEND.LEN);
  111.     PRINT #1, LEFT$(B$,SEND.LEN);
  112.     WHILE LOC(1)=0
  113.     WEND
  114.     T$=INPUT$(1,#1)
  115.     IF T$<>TV$ THEN _
  116.       RC=RC + 1 _
  117.       :LOCATE 10,30 _
  118.       :PRINT RC;"retries" _
  119.       :GOTO SEND.RETRY
  120.     LOCATE 10,30
  121.     PRINT SPACE$(30)
  122.     RETURN
  123.